@extends('admin.common.base-master')

@section('html-head')

@endsection

@section('html-body')
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>

            <a href="{{route('Admin.Home.goodsList')}}">折扣管理</a>
            <em> > </em>
            <a href="#">促销规则列表</a>
        </div>

        @include('admin.common.discount-header')

        <div class="filter-box clearfix">
            <div class="fr">
                <a class="addBtn" href="{{route("Admin.Home.setDiscountSales")}}">新增</a>
            </div>
        </div>
        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>名称</th>
                    <th>类型</th>
                    <th>适用范围</th>
                    <th>满足数量</th>
{{--                    <th>满足金额</th>--}}
                    <th>赠送数量</th>
                    <th>优惠金额</th>
                    <th>优惠折扣率</th>
                    <th>优惠开始时间</th>
                    <th>优惠截至时间</th>
                    <th>创建时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if(count($rules) > 0)
                    @foreach($rules as $rule)
                        <tr>
                            <td>{{$rule->id}}</td>
                            <td>{{$rule->name}}</td>
                            <td>@if($rule->type == 'buy_get_free')
                                    满数量-赠送
                                @elseif($rule->type == 'reduce')
                                    满数量-订单减金额
                                @elseif($rule->type == 'discount')
                                    满数量-订单总价打折
                                @else
                                    无效类型
                                @endif</td>
                            <td>
                                @if($rule->range == 'vip')
                                    会员
                                @else
                                    所有用户
                                @endif
                            </td>
                            <td>{{$rule->satisfy_number}}</td>
{{--                            <td>{{$rule->satisfy_amount}}</td>--}}
                            <td>@if($rule->type == 'buy_get_free'){{$rule->free_get_number}}@else / @endif</td>
                            <td>@if($rule->type == 'reduce'){{$rule->reduce_amount}}@else / @endif</td>
                            <td>@if($rule->type == 'discount'){{$rule->reduce_rate}}@else / @endif</td>
                            <td>@if($rule->start_time){{$rule->start_time}}@else 无限制 @endif</td>
                            <td>@if($rule->end_time){{$rule->end_time}}@else 无限制 @endif</td>
                            <td>{{$rule->created_at}}</td>
                            <td>
                                @if($rule->status == 1)
                                    启用
                                @else
                                    禁用
                                @endif
                            </td>
                            <td>
                                <a class="color2" href="{{route("Admin.Home.setDiscountSales")}}?id={{$rule->id}}">编辑</a>
                                <span>|</span>
                                <a href="javascript:void(0);" class="del" data-id="{{$rule->id}}">删除 </a>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
        </div>
        <?php echo $rules->render(); ?>
    </div>
@endsection